<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var deptName = document.getElementById("deptName");
		
		if(deptName.value == ""){
			alert("<fmt:message key='dept.lable.deptName'/><fmt:message key='common.message.empty'/>");
			return false;
		}
		return true;
	}
	
	function save(){
		if(checkForm()){
			document.addDepartmentForm.action = "./department.do?action=addDepartment";
			document.addDepartmentForm.target = "departmentFrame";
			document.addDepartmentForm.submit();
		}
	}
	
	function initPage(result,repeat){
		//parent.location.reload();
		if(result == 1){
			alert("<fmt:message key='common.message.addSuccess'/>");
			parent.location.reload();
		}
		if(repeat == 1){
			alert("<fmt:message key='common.message.addFail'/><fmt:message key='dept.lable.deptName'/><fmt:message key='common.message.exist'/>");
		}
	}
-->
</script>
</head>
<body onload="initPage('${result}','${repeat}')">
<form name="addDepartmentForm" action="" method="post">
	<table class="table2" cellpadding="0" cellspacing="0" style="height: 100%;">
		<tr>
			<td valign="top">
				<table class="table_lab" cellpadding="0" cellspacing="0" style="width: 100%;">
					<tr>
						<td height="25" class="title">
							&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='dept.title.add'/>
						</td>
					</tr>
					<tr>
						<td valign="bottom" align="right">
							<a href="javascript:save();" title="<fmt:message key='common.button.save'/>" hidefocus="true"><fmt:message key='common.button.save'/></a>&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr><td class="line3"></td></tr>
		<tr>
			<td>
				<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 50px;">
					<tr>
						<td width="15%" height="30"><fmt:message key='dept.lable.deptCode'/><fmt:message key='common.sign'/></td>
						<td>${deptCode}<input id="deptCode" name="deptCode" type="hidden" value="${deptCode}"/></td>
					</tr>
					<tr>
						<td width="15%" height="30"><fmt:message key='dept.lable.deptName'/><fmt:message key='common.sign'/></td>
						<td><input id="deptName" name="deptName" class="input_long" type="text" value="${department.deptName}"/>*</td>
					</tr>
					<!-- 
					<tr>
						<td width="15%" height="30">部门英文名称：</td>
						<td><input id="deptNameEn" name="deptNameEn" class="input_long" type="text" value="${department.deptNameEn}"/></td>
					</tr>
					 -->
					<tr>
						<td width="15%" height="30"><fmt:message key='dept.lable.parent'/><fmt:message key='common.sign'/></td>
						<td>
							<select id="parentId" name="parentId">
								<option value="0" <c:if test='${department.parentId == 0}'>selected</c:if> >
									-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</option>
								<c:forEach var="sdepartment" items="${departments}">
								<option value="${sdepartment.id}" <c:if test='${sdepartment.id == department.parentId}'>selected</c:if> >
									${sdepartment.deptName}
								</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td colspan="2" height="50"></td>
					</tr>
					<tr>
						<td colspan="2" height="30"><fmt:message key='dept.remark'/></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>